package com.ttbj.product.bean.dto;

import java.io.Serializable;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

public class Distance implements Serializable {

	private static final long serialVersionUID = 3630640320602011874L;

	private int BASE_KILOMETER = 1000;

	private int BASE_MINUTE = 60;

	@Min(value = 1, message = "距离不允许小于等于1米")
	@NotNull(message = "未获取到距离,请重新选择位置")
	private Float distance; // 距离(单位：米)

	private Integer duration; // 时间(单位:秒)

	private CoordDto to; // 结束点

	private CoordDto from; // 开始点

	private Float kilometer; // 公里

	private Integer minute; // 分钟

	private Float price; // 价格

	public Float getPrice(Float unitPrice) {
		if (null == unitPrice) {
			unitPrice = 0f;
		}
		return  getKilometer() * unitPrice;
	}

	public Float getKilometer() {
		if (distance == null || distance < 1f) {
			return 0f;
		}
		return distance / BASE_KILOMETER;
	}

	public Integer getMinute() {
		if (duration == null || duration == 0) {
			return 0;
		}
		return duration / BASE_MINUTE;
	}

	public Float getDistance() {
		return distance;
	}

	public void setDistance(Float distance) {
		this.distance = distance;
	}

	public Integer getDuration() {
		return duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	public CoordDto getTo() {
		return to;
	}

	public void setTo(CoordDto to) {
		this.to = to;
	}

	public CoordDto getFrom() {
		return from;
	}

	public void setFrom(CoordDto from) {
		this.from = from;
	}

	@Override
	public String toString() {
		return "DistanceVo [distance=" + distance + ", duration=" + duration + ", to=" + to + ", from=" + from + ", kilometer=" + kilometer + ", minute=" + minute + "]";
	}

}
